<include file="Public:header" />
<link  href="__JS__/viewer/viewer.min.css" rel="stylesheet">
<script src="__JS__/viewer/viewer.min.js"></script>

<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl">
                    <h3>{$status[$zlbt[state]]}详情 /
                        <em>{$zlbt.no}</em>（<em name="title">{$status[$zlbt[state]]}</em>）
                    </h3>
                </div>
                <div class="fr hidden">
                    <form class="search-form" method="post" action="">
                        <input name="field" value="{$context.field}" type="hidden" />
                        <input name="value" value="{$context.value}" type="hidden" />
                        <input name="state" value="{$context.state}" type="hidden" />
                        <input name="page" value="{$context.page}" type="hidden" />
                        <input name="order_field" value="{$context.order_field}" type="hidden" />
                        <input name="order_sort" value="{$context.order_sort}" type="hidden" />
                        <input name="offset" value="{$context.offset}" type="hidden" />
                        <input name="where" value='{$context.where}' type="hidden" />
                        <input name="id" value="{$context.id}" type="hidden" />
                    </form>
                </div>
            </div>
            <div class="line2">
                <!-- 编辑按钮组 -->
                <div class="fl form-btn-group btn-group-edit">
                    <in name="$x|default='01-03-12'" value="$rightsCode">
                        <button onclick="action_bufaDlg();" class="btn-save btn-highlight">补发租赁补贴</button>
                        <else />
                        <button disabled="disabled" class="btn-save btn-disable">补发租赁补贴</button>
                    </in>
                    <span>或</span>
                    <a class="linkBtn btn-abort" href="javascript:history.go(-1);">返回</a>
                </div>
                <!-- 保存按钮组 -->
                <div class="fl form-btn-group btn-group-save hidden">
                    <button onclick="action_save();" class="btn-save btn-highlight">保 存</button>
                    <span>或</span>
                    <a class="linkBtn btn-abort" onclick="action_abort();" href="javascript:void(0);">放弃</a>
                </div>
                <div class="fl form-btn-more">
                    <button class="btn-normal btn-more">
                        更多操作<i class="drop-down"></i>
                    </button>
                    <ul class="more-action hidden">
                        <li><a onclick="action_blacklist();" href="javascript:void(0);">移入黑名单</a></li>
                    </ul>
                </div>
                <div class="fr form-search-count">
                    <span class="index">{$context.index}/{$page.total}</span>
                    <button name="prev" onclick="ItemJump({$page.prev.id}, {$page.prev.offset});" class="btn-normal">上一条</button>
                    <button name="next" onclick="ItemJump({$page.next.id}, {$page.next.offset});" class="btn-normal">下一条</button>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2" style="margin-bottom: 4px;">
        <include file="Public:zlbtDetail" />
    </div>
</div>
<include file="Public:blacklist_dialog" />
<div class="dialog bufaDlg hidden">
    <div class="box">
        <div class="title">
            <h4 class="fl">补发租赁补贴对话框</h4>
            <span class="fr"><a href="#" onclick="closeDialog();">关闭</a></span>
        </div>
        <table class="form-tab">
            <tr>
                <th width="90">补发季度：</th>
                <td>
                    <input type="hidden" name="amount" value="{$zlbt.amount}" />
                    <volist name="periods" id="vo" key="index">
                        <div>
                            <if condition="$vo[1]">
                                <input value="{$vo[0]}" type="checkbox" name="period" />
                            <else />
                                <input disabled="disabled" value="{$vo[0]}" type="checkbox" name="period" />
                            </if>
                            <label>{$vo[2]}年{$vo[3]}季度</label>
                        </div>
                    </volist>
                </td>
            </tr>
            <tr>
                <th>补发金额：</th>
                <td>
                    <input disabled="disabled" name="total" value="0.00"  type="text" />
                </td>
            </tr>
            <tr>
                <th width="90">补发日期：</th>
                <td>
                    <input name="tcrq" type="text" value="{$ctime|default=time()|date='Y/m/d',###}" />
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align: center;line-height:40px;">
                    <button class="btn btn-highlight" onclick="action_bufa();">提交</button>
                    <span>或</span>
                    <a href="#" onclick="closeDialog();" class="linkBtn">放弃</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<script>
    function action_bufaDlg(){
        $(".bufaDlg").show();
    }

    function action_bufa(){
        var id = $("input[name=id]").val();
        var periods = new Array();
        $("input[name=period]").each(function(){
            if($(this).is(":checked")){
                periods.push($(this).val());
            }
        });
        if(periods.length==0){
            alert("操作失败，请选择要补发的季度");
            return false;
        }
        $.ajax({
            url:"/admin/zlbt/ajax_Bufa",
            data: {id: id, periods: periods}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("操作成功");
                    location.reload();
                }else{
                    alert(data.info);
                }
            }
        });
    }

    $("input[name=period]").click(function(){
        var total = 0;
        $("input[name=period]").each(function(){
            if($(this).is(":checked")){
                total += 1;
            }
        });
        var amount_total = parseFloat($("input[name=amount]").val()) * total;
        $("input[name=total]").val(amount_total.toFixed(2));
    });

    /* 错误判断 */
    function action_errCheck(){
        var cno = $("input[name=contact]").val(); //判断旧合同是否过期
        $.ajax({
            url:"/admin/zlbt/ajax_IsContactExpired",
            data: {cno: cno}, type:"POST", dataType:"JSON",
            success: function(data){
                console.log(data);
                if(data){
                    $("a[name=payLink]").attr("href", data.url);
                    showDialog('errorDlg');
                }else{
                    showDialog('refuseDlg');
                }
            }
        });
    }
    function action_tuichu() {
        var id = $("input[name=id]").val();
        var data = {
            tcrq: $("input[name=tcrq]").val(),
            tcyy: $("input[name=tcyy]").val(),
            yajin: $("input[name=yajin]").val()
        };

        if(!data.tcrq){
            alert("退出日期不能为空");
            $("input[name=tcrq]").val();
            return false;
        }
        if(!data.tcyy){
            alert("退出原因不能为空");
            $("input[name=tcyy]").val();
            return false;
        }
        $.ajax({
            url:"/admin/zlbt/ajax_tcbz",
            data: {id:id, data:data}, type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("操作成功，系统自动跳转到下一条记录");
                    ItemJump({$page.next.id}, {$context.offset});//跳转到下一条记录；offset不变
                }else{
                    alert(data.info);
                }
            }
        });
    }
</script>
<include file="Public:footer" />
